﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WellBuilt.Model;

namespace WellBuilt.Service
{
    public class VentShaftService
    {
        internal static VentShaftOut VentShaftResult(VentShaftIn ventShaftIn)
        {
            //传出参数
            VentShaftOut ventShaftOut = new VentShaftOut();
            //平台类型
            string ptType = ventShaftIn.PT_Type;
            //梯子类型
            string tzType = ventShaftIn.TZ_Type;
            //栏栅类型
            string lsType = ventShaftIn.LZ_Type;
            //每层材料-玻璃钢
            //=玻璃钢平台+玻璃钢梯子+玻璃钢栏栅
            double cjj = ventShaftIn.SliceGap;
            double sd = ventShaftIn.Depth;
            double mtmsl = ventShaftIn.Number;
            double blgPT = ptType == "玻璃钢平台" ? (cjj == 4 ? 70 : (cjj == 4.5 ? 77 : 84)) : 0;
            double blgTZ = tzType == "玻璃钢梯子" ? (cjj == 4 ? 93 : (cjj == 4.5 ? 101 : 111)) : 0;
            double blgLS = lsType == "玻璃钢栏栅" ? (cjj == 4 ? 235 : (cjj == 4.5 ? 251 : 295)) : 0;
            double mcBLG = blgPT + blgTZ + blgLS;
            ventShaftOut.MC_Fiberglass = mcBLG;
            //每层材料-钢材(平台钢板+钢梯子+钢栏栅)
            double ptgbdz = 0;
            //=IF(F4=0,IF(C17="δ=6",50.5,IF(C17="δ=5.5",46.6,42.2)),"/")
            switch (ventShaftIn.PT_Standard)
            {
                case "δ=6":
                    ptgbdz = 50.5;
                    break;
                case "δ=5.5":
                    ptgbdz = 46.6;
                    break;
                default:
                    ptgbdz = 42.2;
                    break;
            }
            //spinEdit41.Value =IF(F4=0,ROUND(D17*E17,2),0)
            double gbPT = ptType == "钢板平台" ? Math.Round(ptgbdz * ventShaftIn.PT_Area, 2) : 0;
            double gbTZ = tzType == "钢梯子" ? (cjj == 4 ? 58 : (cjj == 4.5 ? 77 : 84)) : 0;
            double gbLS = lsType == "钢栏栅" ? (cjj == 4 ? 175 : (cjj == 4.5 ? 186 : 212)) : 0;
            double mcGC = Math.Round((ventShaftIn.Total + gbPT + gbTZ + gbLS) * 1.05, 2);
            ventShaftOut.MC_Steel = mcGC;
            //总材料-玻璃钢
            ventShaftOut.ZL_Fiberglass = Math.Round(mcBLG * (Math.Round((sd / cjj + 0.2), 0) + 2 * mtmsl) / 1000, 2);
            //总材料-钢材=ROUND(G24*(ROUND((F2/D3+0.2),0)+2*F3)/1000,2)+N14
            ventShaftOut.ZL_Steel = Math.Round(mcGC * (Math.Round((sd / cjj + 0.2), 0) + 2 * mtmsl) / 1000, 2);

            return ventShaftOut;
        }
    }
}
